home *** CD-ROM | disk | FTP | other *** search
- Path: mayne.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: RS232 & Strings
- Date: 27 Mar 1996 12:34:28 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4jc8okINNahh@mayne.ugrad.cs.ubc.ca>
- References: <Pine.SUN.3.91.960326144705.10920A-100000@Ra.MsState.Edu> <315953AB.47C1@airmail.net>
- NNTP-Posting-Host: mayne.ugrad.cs.ubc.ca
-
- In article <315953AB.47C1@airmail.net>, Mark Nelson <markn@airmail.net> wrote:
- >> I need to be able to receive a string that is ten
- >> char. long (starting w/ a + or - and ending with a <CR> ) from an
- >> external device that is hooked to a PC RS232 port. I have gotten the
- >> port initialized, etc. can receive some data from it, but I need to be
- >> able to receive a string from the device. Using inport and casting
- >
- >You are going to need an interrupt driven routine to receive characters.
- >Trying to read them in using polling is not going to work, because
- >you are inevitably going to miss some characters.
-
- That is false. Polling is the fastest way to receive characters, at the expense
- of everything. You are less likely to miss characters with _continous_ polling
- than with interrupts. The reason modern serial adapters have buffered FIFO
- UARTS is precisely for the reason that interrupt service routines just kick in
- too slowly to keep up with the bps rate! A CPU-wasting polled loop on the same
- hardware could happily ignore the UART, and just pull bytes directly off the
- receive register. I've had one programmer tell me that he transferred a file
- between two 8088 machines at full 115,200 kbps using polled I/O, a feat you
- could not accomplish with an interrupt service routine on the same hardware.
-
- Remember, before you leave a polled loop to do something else, you can always
- assert a hand-shaking signal to prevent overflow while you are ignoring the
- device.
-
- There is no faster way to respond to a device than to monitor its
- status register with a tight loop and do something as soon as you see the
- change you are looking for.
-
- Polled IO in a pre-emptive MT system is different, though. When the routine is
- pre-empted by the kernel, you have trouble!
- --
-
-